[SUBROUTINE]
version = 1.14
icon = threading.png
name = _("Threading")
type = threading
help = _("<b>External or internal thread, metric or imperial (Verify)</b>&#10;Cutter orientation should be 6 for external, 8 for internal or None")
order = act h1 sz ez hdef u d sd sdu sdg p hc hcut dgrs id pk t ta sc

[PARAM_ACT]
name = _("Active")
icon = enable.png
type = bool
value = 1

[PARAM_H1]
name = _("Coords")
type = sub-header

[PARAM_SZ]
name = _("Begin Z")
icon = z.png
type = float
value = 0.0
metric_value = 0.0
;tool_tip = _("Params will be set even if disabled")
header = h1

[PARAM_EZ]
name = _("End Z")
icon = z-end.png
type = float
value = -1.0
metric_value = -25.0
header = h1

[PARAM_HDEF]
name = _("Thread definition")
type = sub-header

[PARAM_U]
name = _("Units")
icon = mm-in.png
type = combo
options = _("Imperial=0:Metric=1")
value = 0
header = hdef
on_init = p.attr['value'] = 1 if default_metric else 0

[PARAM_D]
name = _("Major diameter")
icon = thread-d.png
type = float
value = 0.8
minimum_value = 0.0
not_allowed = 0
header = hdef
on_init = p.attr['value'] = 20 if default_metric else 0.8

[PARAM_SD]
name = _("Minor diameter")
icon = small-diam.png
type = combo-user
options = _("User defined=0:Automatic=1:G-Code=2")
value = 1
links = sdu=0:sdg=2
header = hdef

[PARAM_SDU]
type = float
value = 0.63
minimum_value = 0.0
not_allowed = 0
header = hdef
hidden = 1

[PARAM_SDG]
type = gcode
value = 
header = hdef
hidden = 1

[PARAM_P]
name = _("Pitch")
icon = thread-pitch.png
type = float
value = 10.0
tool_tip = _("Metric pitch is thread to thread, imperial is per inch")
header = hdef
on_init = p.attr['value'] = 1.25 if default_metric else 10.0

[PARAM_HC]
name = _("Starts")
type = int
minimum_value = 1
tool_tip = _("Number of helix")
value = 1
header = hdef
;icon = helix-count.png

[PARAM_HCUT]
name = _("Params")
type = sub-header

[PARAM_DGRS]
name = _("Depth degression")
type = float
value = 1.0
minimum_value = 1.0
maximum_value = 3.0
header = hcut
tool_tip = _("1 = constant depth, 2 = constant area")

[PARAM_PK]
name = _("Thread peak")
;icon = dx.png
type = float
value = 0.04
metric_value = 1.0
not_allowed = 0
header = hcut
tool_tip = _("Positive for external, negative for internal")

[PARAM_ID]
name = _("Init thread depth")
icon = thread-depth2.png
type = float
value = 0.010
metric_value = 0.4
minimum_value = 0.0
not_allowed = 0
tool_tip = _("Depth of first pass in diameter measurement")
header = hcut

[PARAM_T]
name = _("End taper")
;icon = enable.png
type = combo
options = _("None=0:On entry=1:On exit=2:Both=3")
value = 2
;tool_tip = _("Params will be set even if disabled")
header = hcut

[PARAM_TA]
name = _("Taper angle")
icon = angle.png
type = float
value = 30.0
digits = 2
minimum_value = 15.0
maximum_value = 60.0
suffix = &#176;
header = hcut

[PARAM_SC]
name = _("Spring passes")
icon = finish.png
type = int
value = 2
minimum_value = 0
;tool_tip = _("Params will be set even if disabled")
header = hcut


[VALIDATION]
content =
	if #param_act == 1 :
		sd = [#param_sdu, -1, self.check_hash('#param_sdg', 0)][self.check_hash('#param_sd', 1)]
		if (sd >= self.check_hash('#param_d', 0)) :
			VALIDATED = False
			self.msg_inv(_('Major diameter must be greater than minor diameter'), 1)
			
		pk = self.check_hash('#param_pk', 0)
		if (pk > 0.0) and (TOOL_TABLE.get_tool_orient() not in [0, 6]) :
			self.msg_inv(_('Cutter orientation should be 6 or 0'), 3)
		elif (pk < 0.0) and (TOOL_TABLE.get_tool_orient() not in [0, 8]) :
			self.msg_inv(_('Cutter orientation should be 8 or 0'), 3)

[CALL]
content =
	(begin #sub_name)
	(author : Fernand Veilleux)
	
	o<#self_id_act> if [#param_act]
		o<select> CALL [31] [#param_sd] [#param_sdu] [-1] [#param_sdg]
		
		o<threading> CALL [#param_sz] [#param_ez] [#param_u] [#param_d] [#31] [#param_p] [#param_dgrs] [#param_id] [#param_pk] [#param_t] [#param_sc] [#param_ta] [#param_hc]
	o<#self_id_act> endif
	
	(end #sub_name)
